package com.guavamail.smtp;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.charset.Charset;

public class SMTPServerConfig {

	/**
	 * Server name.
	 */
	public static final String NAME = "GuavaMail_Test";

	/**
	 * Server version
	 */
	public static final String VERSION = "0.0.1";

	/**
	 * The default charset is ISO-8859-1.
	 */
	public final static Charset DEFAULT_CHARSET = Charset.forName("ISO-8859-1");

	/**
	 * 4 megs by default. The server will buffer incoming messages to disk when
	 * they hit this limit in the DATA received.
	 */
	public final static int DEFAULT_DATA_DEFERRED_SIZE = 1024 * 1024 * 4;

	/**
	 * The charset in use. Defaults to DEFAULT_CHARSET.
	 */
	private Charset charset = DEFAULT_CHARSET;

	/**
	 * Data limit size before writing it to the disk. Defaults to
	 * DEFAULT_DATA_DEFERRED_SIZE.
	 */
	private int dataDeferredSize = DEFAULT_DATA_DEFERRED_SIZE;

	/**
	 * Set a hard limit on the maximum number of connections this server will
	 * accept once we reach this limit, the server will gracefully reject new
	 * connections. Default is 1000.
	 */
	private int maxConnections = 1000;

	/**
	 * The timeout for waiting for data on a connection is one minute: 1000 *
	 * 60.
	 */
	private int connectionTimeout = 1000 * 60;

	/**
	 * The maximal number of recipients that this server accepts per message
	 * delivery request. Default value is set to 1000.
	 */
	private int maxRecipients = 1000;

	/**
	 * The maximum message size allowed by this SMTP server. The default value,
	 * 0, means no limit.
	 */
	private long maxMessageSize = 0;

	/**
	 * The connection backlog. Defaults to 5000.
	 */
	private int backlog = 5000;

	private String hostName;
	private String systemName = "GuavaMail";

	public SMTPServerConfig() {
		try {
			this.hostName = InetAddress.getLocalHost().getCanonicalHostName();
		} catch (UnknownHostException e) {
			this.hostName = "localhost";
		}
	}

	public int getMaxConnections() {
		return maxConnections;
	}

	public int getConnectionTimeout() {
		return connectionTimeout;
	}

	public String getHostName() {
		return hostName;
	}

	public void setHostName(String hostName) {
		this.hostName = hostName;
	}

	public String getSystemName() {
		return systemName;
	}

	public int getMaxRecipients() {
		return maxRecipients;
	}

	public void setMaxRecipients(int maxRecipients) {
		this.maxRecipients = maxRecipients;
	}

	public Charset getCharset() {
		return charset;
	}

	public void setCharset(Charset charset) {
		this.charset = charset;
	}

	public int getDataDeferredSize() {
		return dataDeferredSize;
	}

	public void setDataDeferredSize(int dataDeferredSize) {
		this.dataDeferredSize = dataDeferredSize;
	}

	public int getBacklog() {
		return backlog;
	}

	public void setBacklog(int backlog) {
		this.backlog = backlog;
	}

	public long getMaxMessageSize() {
		return maxMessageSize;
	}

	public void setMaxMessageSize(long maxMessageSize) {
		this.maxMessageSize = maxMessageSize;
	}

}
